<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
		<form action="${ctx }/admin/employee/save?id=${n.id }" id="detail-form" class="form-horizontal" method="post">
			<div class="form-group">
				 <!-- 用户ID -->
                 <%--<label class="col-sm-2 control-label">用户ID</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="user_id" value="${n.user }">
                </div>&ndash;%&gt;
                 &lt;%&ndash;<div class="col-sm-4">
                 	<input  id="user-id" name="user.id" value="${n.user.id }" class="form-control">
                        <input type="text"  placeholder="请选择用户ID" class="form-control" id="user-name" value="${n.user.id }"

                           onclick="bring({
						                 	url:'${ctx}/admin/user/search',
						                 	name: 'id',
						                 	idInput: 'user-id',
						                 	nameInput: 'user-name'
						                 	})" />

                 </div>--%>

                <%--员工工号--%>
                <label class="col-sm-2 control-label">员工工号</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" id="user_id" name="user_id" value="${n.user_id }">
                </div>

				 <!-- 岗位 -->
                 <label class="col-sm-2 control-label">岗位</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="position" value="${n.position }">
                 </div>
            </div>
            <div class="form-group">

				 <!-- 姓名 -->
                 <label class="col-sm-2 control-label">姓名</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" id="name" name="name" value="${n.name }">
                 </div>
                 
				 <!-- 出生日期 -->
                 <label class="col-sm-2 control-label">出生日期</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" id="birth" name="birth" value="<fmt:formatDate value='${n.birth }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: ''})">
                 </div>
            </div>
            <div class="form-group">     
                 
				 <!-- 性别 -->
                 <label class="col-sm-2 control-label">性别</label>
                <div class="col-sm-4">
                    ${enum:detail('Sex', 'sex', n.sex)}
                </div>
                 
				 <!-- 身高 -->
                 <label class="col-sm-2 control-label">身高</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="height" value="${n.height }">
                 </div>
            </div>
            <div class="form-group">     
                 
				 <!-- 体重 -->
                 <label class="col-sm-2 control-label">体重</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="weight" value="${n.weight }">
                 </div>
                 
				 <!-- 籍贯 -->
                 <label class="col-sm-2 control-label">籍贯</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="place" value="${n.place }">
                 </div>
            </div>
            <div class="form-group">     
                 
				 <!-- 民族 -->
                 <label class="col-sm-2 control-label">民族</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="nation" value="${n.nation }">
                 </div>
                 
				 <!-- 联系电话 -->
                 <label class="col-sm-2 control-label">联系电话</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" id="phone" name="phone"  value="${n.phone }">
                 </div>
            </div>
            <div class="form-group">     
                 
				 <!-- 身份证号 -->
                 <label class="col-sm-2 control-label">身份证号</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" id="iDCard" name="iDCard" value="${n.IDCard }">
                 </div>
                 
				 <!-- 毕业学校 -->
                 <label class="col-sm-2 control-label">毕业学校</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="school" value="${n.school }">
                 </div>
            </div>
            <div class="form-group">     
                 
				 <!-- 专业 -->
                 <label class="col-sm-2 control-label">专业</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="major" value="${n.major }">
                 </div>
                 
				 <!-- 学历 -->
                 <label class="col-sm-2 control-label">学历</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="education" value="${n.education }">
                 </div>
            </div>
            <div class="form-group">     
                 
				 <!-- 户口所在地 -->
                 <label class="col-sm-2 control-label">户口所在地</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="location" value="${n.location }">
                 </div>
                 
				 <!-- 居住地址 -->
                 <label class="col-sm-2 control-label">居住地址</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="address" value="${n.address }">
                 </div>
            </div>
            <div class="form-group">     
                 
				 <!-- 微信号 -->
                 <label class="col-sm-2 control-label">微信号</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="wechat" value="${n.wechat }">
                 </div>
                 
				 <!-- 邮箱 -->
                 <label class="col-sm-2 control-label">邮箱</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" id="email" name="email"  value="${n.email }">
                 </div>
            </div>
            <div class="form-group">     
                 
				 <!-- 婚姻状况 -->
                 <label class="col-sm-2 control-label">婚姻状况</label>
                 <div class="col-sm-4">
                     ${enum:detail('Marry', 'marry', n.marry)}
                 </div>
				 <!-- 入职时间 -->
                 <label class="col-sm-2 control-label">入职时间</label>
                 <div class="col-sm-4">
                 	<input type="text" class="form-control" name="inTime" value="<fmt:formatDate value='${n.inTime }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: ''})">
                 </div>
            </div>

            <div class="form-group">
                 
				 <!-- 员工状态/1.录用/2.停职 -->
                 <label class="col-sm-2 control-label">员工状态</label>
                 <div class="col-sm-4">
                 	${enum:detail('EmployeeStatus', 'status', n.status)}
                 </div>
             </div>



            <label></label>
            <%--员工学历表展示--%>
            <div class="form-group">
                <label class="control-label">员工学历：</label>
            </div>
            <div>
                <p>
                    <button type="button" class="btn btn-sm btn-outline btn-primary" onclick="eduAdd()"><i class="fa fa-plus"></i> 新增</button>
                    <button type="button" class="btn btn-sm btn-outline btn-info " onclick="eduEdit()"><i class="fa fa-paste"></i> 详情</button>
                    <button type="button" class="btn btn-sm btn-outline btn-danger" onclick="eduDel()">删除</button>
                </p>
            </div>
            <table id="edu_table" data-toggle="table" data-striped="true" data-click-to-select="true" data-mobile-responsive="true">
                <thead>
                <tr>
                    <th data-field="_state" data-checkbox="true"></th>
                    <th data-field="id" data-visible="false">ID</th>
                    <th data-field="employee.id" data-visible="false">员工id</th>
                    <th data-field="employee.user_id" data-visible="false">员工工号</th>
                    <th data-field="start">学习起始时间</th>
                    <th data-field="end">学习结束时间</th>
                    <th data-field="major">专业</th>
                    <th data-field="record">学历</th>
                    <th data-field="certificate">证书</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${n.educations}" var="n" varStatus="idx" >
                    <c:if test="${n.deleted==false}">
                    <tr data-index="${idx.index }" data-id="${n.id }">
                        <td class="bs-checkbox">
                            <input data-index="0" name="btSelectItem" type="checkbox">
                        </td>
                        <td style="">${n.id }</td>
                        <td style="">${n.employee.id}</td>
                        <td style="">${n.employee.user_id}</td>
                        <td style="">
                            <fmt:formatDate value="${n.start }" pattern="yyyy-MM-dd"/>
                        </td>
                        <td style="">
                            <fmt:formatDate value="${n.end }" pattern="yyyy-MM-dd"/>
                        </td>
                        <td style="">${n.major }</td>
                        <td style="">${n.record }</td>
                        <td style="">${n.certificate }</td>
                    </tr>
                    </c:if>
                </c:forEach>
                </tbody>
            </table>




            <label></label>
            <%--员工紧急联系人展示--%>
            <div class="form-group">
                <label class="control-label">员工紧急联系人:</label>
            </div>
            <div>
                <p>
                    <button type="button" class="btn btn-sm btn-outline btn-primary" onclick="emeAdd()"><i class="fa fa-plus"></i> 新增</button>
                    <button type="button" class="btn btn-sm btn-outline btn-info " onclick="emeEdit()"><i class="fa fa-paste"></i> 详情</button>
                    <button type="button" class="btn btn-sm btn-outline btn-danger" onclick="emeDel();">删除</button>
                </p>
            </div>
            <table id="eme_table" data-toggle="table" data-striped="true" data-click-to-select="true" data-mobile-responsive="true">
                <thead>
                <tr>
                    <th data-field="_state" data-checkbox="true"></th>
                    <th data-field="id" data-visible="false">ID</th>
                    <th data-field="employee" data-visible="false">员工工号</th>
                    <th data-field="name">姓名</th>
                    <th data-field="relation">关系</th>
                    <th data-field="phone">联系电话</th>
                    <th data-field="address">单位或住址</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${n.emergencyContact}" var="n" varStatus="idx">
                    <c:if test="${n.deleted==false}">
                        <tr data-index="${idx.index }" data-id="${n.id }">
                            <td class="bs-checkbox">
                                <input data-index="0" name="btSelectItem" type="checkbox">
                            </td>
                            <td style="">${n.id }</td>
                            <td style="">${n.employee.user_id}</td>
                            <td style="">${n.name}</td>
                            <td style="">${n.relation }</td>
                            <td style="">${n.phone }</td>
                            <td style="">${n.address }</td>
                        </tr>
                    </c:if>
                </c:forEach>
                </tbody>
            </table>





            <label></label>
            <%--员工工作经验展示--%>
            <div class="form-group">
                <label class="control-label">员工工作经验:</label>
            </div>
            <div>
                <p>
                    <button type="button" class="btn btn-sm btn-outline btn-primary" onclick="expAdd()"><i class="fa fa-plus"></i> 新增</button>
                    <button type="button" class="btn btn-sm btn-outline btn-info " onclick="expEdit()"><i class="fa fa-paste"></i> 详情</button>
                    <button type="button" class="btn btn-sm btn-outline btn-danger" onclick="expDel();">删除</button>
                </p>
            </div>
            <table id="exp_table" data-toggle="table" data-striped="true" data-click-to-select="true" data-mobile-responsive="true">
                <thead>
                <tr>
                    <th data-field="_state" data-checkbox="true"></th>
                    <th data-field="id" data-visible="false">ID</th>
                    <th data-field="employee" data-visible="false">员工工号</th>
                    <th data-field="reason">离职原因</th>
                    <th data-field="company">单位</th>
                    <th data-field="work">工作</th>
                    <th data-field="position">职位</th>
                    <th data-field="start">工作起始时间</th>
                    <th data-field="end">工作结束时间</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${n.experience}" var="n" varStatus="idx">
                    <c:if test="${n.deleted==null}">
                        <tr data-index="${idx.index }" data-id="${n.id }">
                            <td class="bs-checkbox">
                                <input data-index="0" name="btSelectItem" type="checkbox">
                            </td>
                            <td style="">${n.id }</td>
                            <td style="">${n.employee.user_id}</td>
                            <td style="">${n.reason }</td>
                            <td style="">${n.company }</td>
                            <td style="">${n.work }</td>
                            <td style="">${n.position }</td>
                            <td style="">
                                <fmt:formatDate value="${n.start }" pattern="yyyy-MM-dd"/>
                            </td>
                            <td style="">
                                <fmt:formatDate value="${n.end }" pattern="yyyy-MM-dd"/>
                            </td>
                        </tr>
                     </c:if>
                </c:forEach>
                </tbody>
            </table>





            <label></label>
            <%--员工家庭成员展示--%>
            <div class="form-group">
                <label class="control-label">员工家庭成员:</label>
            </div>
            <div>
                <p>
                    <button type="button" class="btn btn-sm btn-outline btn-primary" onclick="famAdd()"><i class="fa fa-plus"></i> 新增</button>
                    <button type="button" class="btn btn-sm btn-outline btn-info " onclick="famEdit()"><i class="fa fa-paste"></i> 详情</button>
                    <button type="button" class="btn btn-sm btn-outline btn-danger" onclick="famDel()">删除</button>
                </p>
            </div>
            <table id="fam_table" data-toggle="table" data-striped="true" data-click-to-select="true" data-mobile-responsive="true">
                <thead>
                <tr>
                    <th data-field="_state" data-checkbox="true"></th>
                    <th data-field="id" data-visible="false">ID</th>
                    <th data-field="employee" data-visible="false">员工工号</th>
                    <th data-field="name">姓名</th>
                    <th data-field="relation">关系</th>
                    <th data-field="contact">联系方式</th>
                    <th data-field="age">年龄</th>
                    <th data-field="company">工作单位</th>
                    <th data-field="position">职位</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${n.family}" var="n" varStatus="idx">
                    <c:if test="${n.deleted==null}">
                    <tr data-index="${idx.index }" data-id="${n.id }">
                        <td class="bs-checkbox">
                            <input data-index="0" name="btSelectItem" type="checkbox">
                        </td>
                        <td style="">${n.id }</td>
                        <td style="">${n.employee.user_id}</td>
                        <td style="">${n.name }</td>
                        <td style="">${n.relation }</td>
                        <td style="">${n.contact }</td>
                        <td style="">${n.age }</td>
                        <td style="">${n.company }</td>
                        <td style="">${n.deleted }</td>
                    </tr>
                    </c:if>
                </c:forEach>
                </tbody>
            </table>
		</form>
</div>

<%@include file="/common/foot.jsp" %>
    <script>
        /*员工学历*/
        function eduAdd() {
            layer.open({
                type: 2,
                skin: 'layui-layer-rim', //加上边框
                area: [layer_default_width, layer_default_height], //宽高
                content: "${ctx}/admin/education/detail",
                btn: ['确定', '取消'],
                yes: function(index, layero){ //或者使用btn1
                    var detailForm = layer.getChildFrame('form', index);
                    console.log(detailForm);
                    /*员工工号必填*/
                    var employee_id=$('#query-employee-id',detailForm).val();
                    if (!!!employee_id){alert('请选择员工工号');return false};
                    detailForm.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                layer.close(index);
                                reload();
                            } else {
                            }
                        }
                    });
                }, cancel: function(index){ //或者使用btn2
                    //按钮【按钮二】的回调
                }
            });
        }
        function eduEdit() {
            var selections = $('#edu_table').bootstrapTable('getAllSelections');
            if (selections.length == 0) {
                error(k.msg.requireOne);
                return;
            }
            if (selections.length>1){
                error(k.msg.selectOnlyOne);
                return;
            }
            var id = selections[0].id;
            layer.open({
                type: 2,
                skin: 'layui-layer-rim', //加上边框
                area: [layer_default_width, layer_default_height], //宽高
                content: "${ctx}/admin/education/detail?id="+id,
                btn: ['确定', '取消'],
                yes: function(index, layero){ //或者使用btn1
                    var detailForm = layer.getChildFrame('form', index);
                    console.log(detailForm);
                    /*员工工号必填*/
                    var employee_id=$('#query-employee-id',detailForm).val();
                    if (!!!employee_id){alert('请选择员工工号');return false};
                    detailForm.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                layer.close(index);
                                reload();
                            } else {
                            }
                        }
                    });
                }, cancel: function(index){ //或者使用btn2
                    //按钮【按钮二】的回调
                }
            });
        }
        var page = "${page.page}";
        function reload() {
            page_submit(page);
        }
        function eduDel() {
            var selections = $('#edu_table').bootstrapTable('getAllSelections');
            if (selections.length == 0) {
                error('请选择1条要删除的记录');
                return;
            }
            layer.confirm('确认要删除吗?', {icon: 3, title:'提示'}, function(index){
                var ids = new Array();
                for (var i = 0; i < selections.length; i++) {
                    ids.push(selections[i].id);
                }
                $.ajax({
                    url: "${ctx}/admin/education/delete",
                    data: {
                        ids: ids.join(',')
                    },
                    success: function(data) {
                        if (isSuccess(data)) {
                            layer.close(index);
                            reload();
                        }
                    }
                });
            });
        }

        /*员工紧急联系人*/
        function emeAdd() {
            layer.open({
                type: 2,
                skin: 'layui-layer-rim', //加上边框
                area: [layer_default_width, layer_default_height], //宽高
                content: "${ctx}/admin/emergencyContact/detail",
                btn: ['确定', '取消'],
                yes: function(index, layero){ //或者使用btn1
                    var detailForm = layer.getChildFrame('form', index);
                    console.log(detailForm);
                    /*员工工号必填*/
                    var employee_id=$('#query-employee-id',detailForm).val();
                    if (!!!employee_id){alert('请选择员工工号');return false};
                    /*姓名必填*/
                    var name=$('#name',detailForm).val();
                    if (!!!name){alert('请输入姓名');return false};
                    /*手机号码验证*/
                    var phone = $('#phone', detailForm).val();
                    if(!!!phone){alert('请输入手机号码.');return false;}
                    var phoneReg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
                    if(!phoneReg.test(phone)) {
                        alert('请输入正确的手机号码.');
                        return false;
                    }

                    detailForm.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                layer.close(index);
                                reload();
                            } else {
                            }
                        }
                    });
                }, cancel: function(index){ //或者使用btn2
                    //按钮【按钮二】的回调
                }
            });
        }

        function emeEdit() {
            var selections = $('#eme_table').bootstrapTable('getAllSelections');
            if (selections.length == 0) {
                error(k.msg.requireOne);
                return;
            }
            if (selections.length>1){
                error(k.msg.selectOnlyOne);
                return;
            }
            var id = selections[0].id;
            layer.open({
                type: 2,
                skin: 'layui-layer-rim', //加上边框
                area: [layer_default_width, layer_default_height], //宽高
                content: "${ctx}/admin/emergencyContact/detail?id="+id,
                btn: ['确定', '取消'],
                yes: function(index, layero){ //或者使用btn1
                    var detailForm = layer.getChildFrame('form', index);
                    console.log(detailForm);
                    /*员工工号必填*/
                    var employee_id=$('#query-employee-id',detailForm).val();
                    if (!!!employee_id){alert('请选择员工工号');return false};
                    /*姓名必填*/
                    var name=$('#name',detailForm).val();
                    if (!!!name){alert('请输入姓名');return false};
                    /*手机号码验证*/
                    var phone = $('#phone', detailForm).val();
                    if(!!!phone){alert('请输入手机号码.');return false;}
                    var phoneReg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
                    if(!phoneReg.test(phone)) {
                        alert('请输入正确的手机号码.');
                        return false;
                    }

                    detailForm.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                layer.close(index);
                                reload();
                            } else {
                            }
                        }
                    });
                }, cancel: function(index){ //或者使用btn2
                    //按钮【按钮二】的回调
                }
            });
        }
        var page = "${page.page}";
        function reload() {
            page_submit(page);
        }
        function emeDel() {
            var selections = $('#eme_table').bootstrapTable('getAllSelections');
            if (selections.length == 0) {
                error('请选择1条要删除的记录');
                return;
            }
            layer.confirm('确认要删除吗?', {icon: 3, title:'提示'}, function(index){
                var ids = new Array();
                for (var i = 0; i < selections.length; i++) {
                    ids.push(selections[i].id);
                }
                $.ajax({
                    url: "${ctx}/admin/emergencyContact/delete",
                    data: {
                        ids: ids.join(',')
                    },
                    success: function(data) {
                        if (isSuccess(data)) {
                            layer.close(index);
                            reload();
                        }
                    }
                });
            });
        }

        /*员工工作经验*/
        function expAdd() {
            layer.open({
                type: 2,
                skin: 'layui-layer-rim', //加上边框
                area: [layer_default_width, layer_default_height], //宽高
                content: "${ctx}/admin/experience/detail",
                btn: ['确定', '取消'],
                yes: function(index, layero){ //或者使用btn1
                    var detailForm = layer.getChildFrame('form', index);
                    console.log(detailForm);
                    /*员工工号必填*/
                    var employee_id=$('#query-employee-id',detailForm).val();
                    if (!!!employee_id){alert('请选择员工工号');return false};
                    detailForm.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                layer.close(index);
                                reload();
                            } else {
                            }
                        }
                    });
                }, cancel: function(index){ //或者使用btn2
                    //按钮【按钮二】的回调
                }
            });
        }

        function expEdit() {
            var selections = $('#exp_table').bootstrapTable('getAllSelections');
            if (selections.length == 0) {
                error(k.msg.requireOne);
                return;
            }
            if (selections.length>1){
                error(k.msg.selectOnlyOne);
                return;
            }
            var id = selections[0].id;
            layer.open({
                type: 2,
                skin: 'layui-layer-rim', //加上边框
                area: [layer_default_width, layer_default_height], //宽高
                content: "${ctx}/admin/experience/detail?id="+id,
                btn: ['确定', '取消'],
                yes: function(index, layero){ //或者使用btn1
                    var detailForm = layer.getChildFrame('form', index);
                    console.log(detailForm);
                    /*员工工号必填*/
                    var employee_id=$('#query-employee-id',detailForm).val();
                    if (!!!employee_id){alert('请选择员工工号');return false};
                    detailForm.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                layer.close(index);
                                reload();
                            } else {
                            }
                        }
                    });
                }, cancel: function(index){ //或者使用btn2
                    //按钮【按钮二】的回调
                }
            });
        }
        var page = "${page.page}";
        function reload() {
            page_submit(page);
        }
        function expDel() {
            var selections = $('#exp_table').bootstrapTable('getAllSelections');
            if (selections.length == 0) {
                error('请选择1条要删除的记录');
                return;
            }
            layer.confirm('确认要删除吗?', {icon: 3, title:'提示'}, function(index){
                var ids = new Array();
                for (var i = 0; i < selections.length; i++) {
                    ids.push(selections[i].id);
                }
                $.ajax({
                    url: "${ctx}/admin/experience/delete",
                    data: {
                        ids: ids.join(',')
                    },
                    success: function(data) {
                        if (isSuccess(data)) {
                            layer.close(index);
                            reload();
                        }
                    }
                });
            });
        }

        /*员工家庭成员*/
        function famAdd() {
            layer.open({
                type: 2,
                skin: 'layui-layer-rim', //加上边框
                area: [layer_default_width, layer_default_height], //宽高
                content: "${ctx}/admin/family/detail",
                btn: ['确定', '取消'],
                yes: function(index, layero){ //或者使用btn1
                    var detailForm = layer.getChildFrame('form', index);
                    console.log(detailForm);
                    /*员工工号必填*/
                    var employee_id=$('#query-employee-id',detailForm).val();
                    if (!!!employee_id){alert('请选择员工工号');return false};
                    /*姓名必填*/
                    var name=$('#name',detailForm).val();
                    if (!!!name){alert('请输入姓名');return false};
                    /*手机号码验证*/
                    var phone = $('#phone', detailForm).val();
                    if(!!!phone){alert('请输入手机号码.');return false;}
                    var phoneReg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
                    if(!phoneReg.test(phone)) {
                        alert('请输入正确的手机号码.');
                        return false;
                    }

                    detailForm.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                layer.close(index);
                                reload();
                            } else {
                            }
                        }
                    });
                }, cancel: function(index){ //或者使用btn2
                    //按钮【按钮二】的回调
                }
            });
        }

        function famEdit() {
            var selections = $('#fam_table').bootstrapTable('getAllSelections');
            if (selections.length == 0) {
                error(k.msg.requireOne);
                return;
            }
            if (selections.length>1){
                error(k.msg.selectOnlyOne);
                return;
            }
            var id = selections[0].id;
            layer.open({
                type: 2,
                skin: 'layui-layer-rim', //加上边框
                area: [layer_default_width, layer_default_height], //宽高
                content: "${ctx}/admin/family/detail?id="+id,
                btn: ['确定', '取消'],
                yes: function(index, layero){ //或者使用btn1
                    var detailForm = layer.getChildFrame('form', index);
                    console.log(detailForm);
                    /*员工工号必填*/
                    var employee_id=$('#query-employee-id',detailForm).val();
                    if (!!!employee_id){alert('请选择员工工号');return false};
                    /*姓名必填*/
                    var name=$('#name',detailForm).val();
                    if (!!!name){alert('请输入姓名');return false};
                    /*手机号码验证*/
                    var phone = $('#phone', detailForm).val();
                    if(!!!phone){alert('请输入手机号码.');return false;}
                    var phoneReg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
                    if(!phoneReg.test(phone)) {
                        alert('请输入正确的手机号码.');
                        return false;
                    }

                    detailForm.ajaxSubmit({
                        success: function(data) {
                            if (isSuccess(data)) {
                                layer.close(index);
                                reload();
                            } else {
                            }
                        }
                    });
                }, cancel: function(index){ //或者使用btn2
                    //按钮【按钮二】的回调
                }
            });
        }
        var page = "${page.page}";
        function reload() {
            page_submit(page);
        }
        function famDel() {
            var selections = $('#fam_table').bootstrapTable('getAllSelections');
            if (selections.length == 0) {
                error('请选择1条要删除的记录');
                return;
            }
            layer.confirm('确认要删除吗?', {icon: 3, title:'提示'}, function(index){
                var ids = new Array();
                for (var i = 0; i < selections.length; i++) {
                    ids.push(selections[i].id);
                }
                $.ajax({
                    url: "${ctx}/admin/family/delete",
                    data: {
                        ids: ids.join(',')
                    },
                    success: function(data) {
                        if (isSuccess(data)) {
                            layer.close(index);
                            reload();
                        }
                    }
                });
            });

        }
    </script>
</body>
</html>
